package spzx.service.impl;

import com.atguigu.spzx.model.entity.product.Brand;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import spzx.mapper.BrandMapper;
import spzx.service.BrandService;

import java.util.List;

@Service
public class BrandServiceImpl implements BrandService {

    @Autowired
    private BrandMapper brandMapper;
    @Override
    public void addBrand(Brand brand) {
        brandMapper.addBrand(brand);
    }

    @Override
    public void updateBrand(Brand brand) {
        brandMapper.updateBrand(brand);
    }

    @Override
    public void deleteBrand(Long id) {
        brandMapper.deleteBrand(id);
    }

    @Override
    public PageInfo getBrand(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Brand> list = brandMapper.getBrand();
        return new PageInfo(list);
    }

    @Override
    public List<Brand> findAll() {
        return brandMapper.getBrand();
    }

    @Override
    public List<Brand> findByCategory3Id(Long category3Id) {
        return brandMapper.findByCategory3Id(category3Id);
    }
}
